package com.nuanshui.heatedloan.baseservice.service.userapply;

import com.nuanshui.heatedloan.baseservice.dal.mapper.OpinionMapper;
import com.nuanshui.heatedloan.baseservice.facade.userapply.OpinionService;
import com.nuanshui.heatedloan.baseservice.model.Opinion;
import com.nuanshui.heatedloan.constant.TransactionManagerType;
import com.nuanshui.heatedloan.pageable.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service("opinionService")
@Transactional(readOnly=true,value=TransactionManagerType.BASE_SERVICE_TRANSACTION_MANAGER)
public class OpinionServiceImpl  implements OpinionService {

	
	@Autowired
	private OpinionMapper opinionMapper;
	
	/**
	 * 保存建议信息
	 * @param 
	 * @author guohao
	 * @date 2015年6月9日 下午3:09:01
	 * @sine 1.3.0
	 */
	@Override
	@Transactional(TransactionManagerType.BASE_SERVICE_TRANSACTION_MANAGER)
	public void saveOpinion(Opinion opinion){
		opinionMapper.saveOpinion(opinion);
	}

	/**
	 * 获得所有反馈意见
	 */

	public Pager<Opinion> list(Pager<Opinion> pager) {
		List<Opinion> list=opinionMapper.list(pager);
		pager.setData(list);
		return pager;
	}

	@Override
	@Transactional(TransactionManagerType.BASE_SERVICE_TRANSACTION_MANAGER)
	public boolean updateOpinion(Opinion opinion) {
		return opinionMapper.updateOpinion(opinion)>0?true:false;
	}

	@Override
	@Transactional(TransactionManagerType.BASE_SERVICE_TRANSACTION_MANAGER)
	public boolean deleteOpinion(String id) {
		return opinionMapper.deleteOpinion(id)>0?true:false;
	}
}
